<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('员工用户列表')"/>
    <th:block th:include="include :: layout-latest-css" />

</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>员工号：</p>
                            <input type="text" name="number"/>
                        </li>
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <p>手机号：</p>
                            <input type="text" name="iphone"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="wechatprogram:WxUser:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="wechatprogram:WxUser:import">
                <i class="fa fa-upload"></i> 导入用户
            </a>
            <a class="btn btn-primary" href="javascript:void(0)" onclick="addAllBalance()" shiro:hasPermission="wechatprogram:WxUser:addAllBalance">
                <i class="fa fa-edit"></i> 批量增加金额
            </a>
            <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="wechatprogram:WxUser:remove">-->
            <!--                    <i class="fa fa-remove"></i> 删除-->
            <!--                </a>-->
            <!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="wechatprogram:WxUser:export">-->
            <!--                    <i class="fa fa-download"></i> 导出-->
            <!--                 </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>

<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('wechatprogram:WxUser:edit')}]];
    var removeFlag = [[${@permission.hasPermi('wechatprogram:WxUser:remove')}]];
    var resetPasswordFlag = [[${@permission.hasPermi('wechatprogram:WxUser:resetPassword')}]];
    var prefix = ctx + "wechatprogram/WxUser";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            modalName: "员工用户",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'number',
                    title: '员工号'
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'iphone',
                    title: '手机号'
                },
                {
                    field: 'card',
                    title: '身份证'
                },
                {
                    field: 'department',
                    title: '部门'
                },
                {
                    field: 'address',
                    title: '地址'
                },
                {
                    field: 'balance',
                    title: '余额'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + resetPasswordFlag + '" href="javascript:void(0)" onclick="editBalance(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改余额</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + resetPasswordFlag + '" href="javascript:void(0)" onclick="resetPassword(\'' + row.id +'\',\''+ row.name + '\')"><i class="fa fa-key"></i>重置密码</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    
    //批量设置金额
    function addAllBalance() {
        $.modal.openTab1("批量增加所有员工的金额", prefix + "/addAllBalance");
    }
    //用户单独设置金额
    function editBalance(id) {
        $.modal.openTab1("修改员工的余额", prefix + "/editBalance/" + id);
    }
    //重置用户密码
    function resetPassword(id,name) {
        $.modal.confirm("确定重置用户" +  "(" +name+ ")" +"的密码吗？", function () {
            var url = prefix + "/resetPassword/" + id;
            $.operate.submit(url, "post");
        });
    }
</script>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                &nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i
                    class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</body>
</html>